﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Web Camera</title>
	<link rel="stylesheet" href="jquery/css/jquery.ui.all.css" />
	<link rel="stylesheet" href="css/common.css" />
	<script src="jquery/jquery-1.9.1.min.js"></script>
	<script src="jquery/jquery.ui.core.js"></script>
	<script src="jquery/jquery.ui.widget.js"></script>
	<script src="jquery/jquery.ui.mouse.js"></script>
	<script src="jquery/jquery.ui.slider.js"></script>
	<script src="jquery/json2.js"></script>
	<script src="js/network.js"></script>
	<script src="js/common.js"></script>
</head>
<script  type="text/javascript"> 
//语言包初始化
document.write(GetLanguagePathStr());
</script>
<style type="text/css">
.DestinationDiv{
	background:#1c1d22;
	left:0px;
	right:0px;
	height:240px;
}

.DivLable{
	text-align:left;
	line-height: 23px;
	font-family:arial;
	font-style:regular;
	font-size:16px;
	color:#ffffff;
	height:23px;
	cursor: pointer;
}


.DivInputAtLoacalRecord{
	width:280px;
	float:left;
}

.DivInputIpv4Param{
	width:50px;
	float:left;
}

#id_txtLocalrecordpath{
	width:160px;
	float:left;
}

.DestinationtxtNature{
	width:160px;
	float:left;
}

.DestinationtxtAction{
	width:320px;
	float:left;
}

</style> 

<script  type="text/javascript">
var checkState = null;

function InitPageParam()
{
	
	var resp = $.sendMsg("NasPath",null,"/ISAPI/Network/NasPath","POST");
	if(resp.success == false){
		alert("recv NasPath msg fail");
		return;
	}
	var map = resp.data;
	console.log( JSON.stringify(map));
	if('0' == map.storelocation){
		checkState = 'Local';
		SetCheckBox('id_RecordLocal0',TranslationStrAndBool(map.motionrec));
		SetCheckBox('id_RecordLocal1',TranslationStrAndBool(map.sensorrec));
		SetCheckBox('id_RecordLocal2',TranslationStrAndBool(map.recenabled));
	}else if('1' == map.storelocation){
		checkState = 'Ftp';
		SetCheckBox('id_RecordFtp0',TranslationStrAndBool(map.motionrec));
		SetCheckBox('id_RecordFtp1',TranslationStrAndBool(map.sensorrec));
		SetCheckBox('id_RecordFtp2',TranslationStrAndBool(map.recenabled));
	}else if('2' == map.storelocation){
		checkState = 'Nas';
		SetCheckBox('id_RecordNas0',TranslationStrAndBool(map.motionrec));
		SetCheckBox('id_RecordNas1',TranslationStrAndBool(map.sensorrec));
		SetCheckBox('id_RecordNas2',TranslationStrAndBool(map.recenabled));
	}
	
	if(('0' == map.motionrec) && ('0' == map.sensorrec) && ('0' == map.recenabled)){
		checkState = null;
	}
}

function submit()
{
	var StoreLocation,MotionRec,SensorRec,RecEnabled;
	
	if((GetCheckBoxValue('id_RecordLocal0') == "true") 
	 ||(GetCheckBoxValue('id_RecordLocal1') == "true")
	 ||(GetCheckBoxValue('id_RecordLocal2') == "true"))
	 {
		StoreLocation = '0';
		if(GetCheckBoxValue('id_RecordLocal0') == "false"){
			MotionRec = "0";
		}else{
			MotionRec = "1";
		}
		if(GetCheckBoxValue('id_RecordLocal1') == "false"){
			SensorRec = "0";
		}else{
			SensorRec = "1";
		}
		if(GetCheckBoxValue('id_RecordLocal2') == "false"){
			RecEnabled = "0";
		}else{
			RecEnabled = "1";
		}
	}else if((GetCheckBoxValue('id_RecordFtp0') == "true") 
	 ||(GetCheckBoxValue('id_RecordFtp1') == "true")
	 ||(GetCheckBoxValue('id_RecordFtp2') == "true")){
		StoreLocation = '1';
		if(GetCheckBoxValue('id_RecordFtp0') == "false"){
			MotionRec = "0";
		}else{
			MotionRec = "1";
		}
		if(GetCheckBoxValue('id_RecordFtp1') == "false"){
			SensorRec = "0";
		}else{
			SensorRec = "1";
		}
		if(GetCheckBoxValue('id_RecordFtp2') == "false"){
			RecEnabled = "0";
		}else{
			RecEnabled = "1";
		}
	 }else if((GetCheckBoxValue('id_RecordNas0') == "true") 
	 ||(GetCheckBoxValue('id_RecordNas1') == "true")
	 ||(GetCheckBoxValue('id_RecordNas2') == "true")){
		StoreLocation = '2';
		if(GetCheckBoxValue('id_RecordNas0') == "false"){
			MotionRec = "0";
		}else{
			MotionRec = "1";
		}
		if(GetCheckBoxValue('id_RecordNas1') == "false"){
			SensorRec = "0";
		}else{
			SensorRec = "1";
		}
		if(GetCheckBoxValue('id_RecordNas2') == "false"){
			RecEnabled = "0";
		}else{
			RecEnabled = "1";
		}
	 }
	
	var msgback = [
					{"xtype":"StoreLocation","text":StoreLocation},
					{"xtype":"motionrec","text":MotionRec},
					{"xtype":"sensorrec","text":SensorRec},
					{"xtype":"recenabled","text":RecEnabled}
				];

	var resp = $.sendMsg("NasPath",msgback,"/ISAPI/Network/NasPath","PUT");
    //console.log(JSON.stringify(msgback));
	if(resp.success == false){
		alert("submit msg fail");
	}else{
		alert(str_SetSuccess);
	}	
}

function CheckBoxEvent(id)
{
	//获取前一次的选择是第几行,并且记录选中的列数。
	//前一次选择的行列归0
	//将上一次选中的列数 复制到当前行状态
	var id_recordLoacal = 'id_RecordLocal';
	var id_RecordFtp = 'id_RecordFtp';
	var id_RecordNas = 'id_RecordNas';
/*	var checkState;
	for(var i = 0; i < 3; i++){
		if( GetCheckBoxValue(id_recordLoacal+i) == 'true'){
			checkState = 'Local';
			break;
		}
		if( GetCheckBoxValue(id_RecordFtp+i) == 'true'){
			checkState = 'Ftp';
			break;
		}
		if(GetCheckBoxValue(id_RecordNas+i) == 'true'){
			checkState = 'Nas';
			break;
		}
	}*/
	
	//alert(checkState);
	//alert('id_Record'+checkState+0);
	
	var str = ""+id;
	var strFront = 'id_Record';
	var lineStr = str.substr(strFront.length,str.length-strFront.length);
	lineStr = lineStr.substr(0,lineStr.length - 1);
	if(lineStr == checkState){
		return;
	}
	if(checkState != null){
		var line1 = GetCheckBoxValue('id_Record'+checkState+0);
		var line2 =  GetCheckBoxValue('id_Record'+checkState+1);
		var line3 = GetCheckBoxValue('id_Record'+checkState+2);
		SetCheckBox('id_Record'+checkState+0,'false');
		SetCheckBox('id_Record'+checkState+1,'false');
		SetCheckBox('id_Record'+checkState+2,'false');
	}else{
		line1 = 'false';
		line2 = 'false';
		line3 = 'false';
	}	
	SetCheckBox('id_Record'+lineStr+0,line1);
	SetCheckBox('id_Record'+lineStr+1,line2);
	SetCheckBox('id_Record'+lineStr+2,line3);
	SetCheckBox(id,'true');
	checkState = lineStr;
	return;
}

</script>
<body>   
<div class="DestinationDiv" style="min-width:600px;">
	<div style="height:100%;margin:auto;width:600px;">	
		<div id="Record" style="float:left;width:650px;height:135px;">
		<div style="clear:both;height:15px;width:650px;"></div>
		<div class="DivLable DestinationtxtNature" id="id_txtRecord">Record</div>	
		<div style="clear:both;height:15px;width:650px;"></div>
		<div style="width:650px;height:100px;float:left;">
		<div style="width:650px;height:25px;">
		<div class="DivLable DestinationtxtNature" id="id_txtRecordEventType">Event Type</div>
		<div class="DivLable DestinationtxtNature" id="id_txtRecordScheduled">Scheduled</div>
		<div class="DivLable DestinationtxtNature" id="id_txtRecordMotionDetect">Motion Detect</div>
		<div class="DivLable DestinationtxtNature" id="id_txtRecordAlarm">Alarm</div>
		</div>
		<div style="width:650px;height:25px;">
		<div class="DivLable DestinationtxtNature" id="id_txtRecordLocal">Local</div>
		<div class="DivCheckBox" style="float:left; margin-left:30px"id="id_RecordLocal0"><script>InitCheckBox('id_RecordLocal0','false',CheckBoxEvent)</script></div>
		<div class="DivCheckBox" style="float:left; margin-left:155px"id="id_RecordLocal1"><script>InitCheckBox('id_RecordLocal1','false',CheckBoxEvent)</script></div>
		<div class="DivCheckBox" style="float:left; margin-left:120px"id="id_RecordLocal2"><script>InitCheckBox('id_RecordLocal2','false',CheckBoxEvent)</script></div>
		</div>
		<div style="width:650px;height:25px;">
		<div class="DivLable DestinationtxtNature" id="id_txtRecordFtp">FTP</div>
		<div class="DivCheckBox" style="float:left; margin-left:30px"id="id_RecordFtp0"><script>InitCheckBox('id_RecordFtp0','fale',CheckBoxEvent)</script></div>
		<div class="DivCheckBox" style="float:left; margin-left:155px"id="id_RecordFtp1"><script>InitCheckBox('id_RecordFtp1','false',CheckBoxEvent)</script></div>
		<div class="DivCheckBox" style="float:left; margin-left:120px"id="id_RecordFtp2"><script>InitCheckBox('id_RecordFtp2','false',CheckBoxEvent)</script></div>
		</div>
		<div style="width:650px;height:25px;">
		<div class="DivLable DestinationtxtNature" id="id_txtRecordNas">NAS</div>
		<div class="DivCheckBox" style="float:left; margin-left:30px"id="id_RecordNas0"><script>InitCheckBox('id_RecordNas0','false',CheckBoxEvent)</script></div>
		<div class="DivCheckBox" style="float:left; margin-left:155px"id="id_RecordNas1"><script>InitCheckBox('id_RecordNas1','false',CheckBoxEvent)</script></div>
		<div class="DivCheckBox" style="float:left; margin-left:120px"id="id_RecordNas2"><script>InitCheckBox('id_RecordNas2','false',CheckBoxEvent)</script></div>
		</div>
		</div>
		</div>
		<!--
		<div id="Snapshot" style="float:left; width:650px;height:135px;">
		<div style="clear:both;height:15px;width:650px;"></div>
		<div class="DivLable DestinationtxtNature" id="id_txtSnapshot">Snapshot</div>
		<div style="clear:both;height:15px;width:650px;"></div>		
		<div style="width:650px;height:100px;float:left;">
		<div style="width:650px;height:25px;float:left;">
		<div class="DivLable DestinationtxtNature" id="id_txtSnapshotEventType">Event Type</div>
		<div class="DivLable DestinationtxtNature" id="id_txtSnapshotScheduled">Scheduled</div>
		<div class="DivLable DestinationtxtNature" id="id_txtSnapshotMotionDetect">Motion Detect</div>
		<div class="DivLable DestinationtxtNature" id="id_txtSnapshotAlarm">Alarm</div>
		</div>
		<div style="width:650px;height:25px;float:left;">
		<div class="DivLable DestinationtxtNature" id="id_txtSnapshotLocal">Local</div>
		<div class="DivCheckBox" style="float:left; margin-left:30px"id="id_SnapshotLocalSchedule"><script>InitCheckBox('id_SnapshotLocalSchedule','true')</script></div>
		<div class="DivCheckBox" style="float:left; margin-left:155px"id="id_SnapshotLocalMotionDetect"><script>InitCheckBox('id_SnapshotLocalMotionDetect','true')</script></div>
		<div class="DivCheckBox" style="float:left; margin-left:120px"id="id_SnapshotLocalAlarm"><script>InitCheckBox('id_SnapshotLocalAlarm','true')</script></div>
		</div>
		<div style="width:650px;height:25px;float:left;">
		<div class="DivLable DestinationtxtNature" id="id_txtSnapshotFtp">FTP</div>
		<div class="DivCheckBox" style="float:left; margin-left:30px"id="id_SnapshotFtpSchedule"><script>InitCheckBox('id_SnapshotFtpSchedule','true')</script></div>
		<div class="DivCheckBox" style="float:left; margin-left:155px"id="id_SnapshotFtpMotionDetect"><script>InitCheckBox('id_SnapshotFtpMotionDetect','true')</script></div>
		<div class="DivCheckBox" style="float:left; margin-left:120px"id="id_SnapshotFtpAlarm"><script>InitCheckBox('id_SnapshotFtpAlarm','true')</script></div>
		</div>
		<div style="width:650px;height:25px;float:left;">
		<div class="DivLable DestinationtxtNature" id="id_txtSnapshotNas">NAS</div>
		<div class="DivCheckBox" style="float:left; margin-left:30px"id="id_SnapshotNasSchedule"><script>InitCheckBox('id_SnapshotNasSchedule','true')</script></div>
		<div class="DivCheckBox" style="float:left; margin-left:155px"id="id_SnapshotNasMotionDetect"><script>InitCheckBox('id_SnapshotNasMotionDetect','true')</script></div>
		<div class="DivCheckBox" style="float:left; margin-left:120px"id="id_SnapshotNasAlarm"><script>InitCheckBox('id_SnapshotNasAlarm','true')</script></div>
		</div>
		</div>
		</div>-->
		<div style="clear:both;height:50px;"></div>	
		<div class="DivButton" style="float:left;margin-left:200px;" id="id_DestinationSubmit">Save</div>
		<div style="clear:both"></div>
	</div>
</div>

</body>

<script  type="text/javascript"> 
//语言包初始化
function InitLang(){
	SetLang('id_txtRecord',str_Recording);
	SetLang('id_txtRecordEventType',str_EventType); 
	SetLang('id_txtRecordScheduled',str_Scheduled);
	SetLang('id_txtRecordMotionDetect',str_SnapTypeMotion);
	SetLang('id_txtRecordAlarm',str_SnapTypeAlarm);
	SetLang('id_DestinationSubmit',str_SDSave);
}
</script> 

<script  type="text/javascript"> 
$(function(){
	InitLang();
	InitPageParam();
	BindEvent('id_DestinationSubmit','onmousedown',submit,null);
})

</script> 

   
</html>  